FROM docker.dm-ai.cn/devops/maven:3.6.2-jdk-8-alpine

COPY . .
RUN mvn clean package -Dmaven.test.skip=true -Dmaven.source.skip=true

FROM docker.dm-ai.cn/devops/openjdk:8-jdk-slim

ENV TZ="Asia/Shanghai"
COPY --from=0 /user-server/target/user-server.jar app.jar

RUN sh -c 'touch /app.jar'
ENV JAVA_OPTS="-Xms768m -Xmx1024m -XX:MetaspaceSize=128m -XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=/logs/heap.hprof -verbose:gc -XX:+PrintGCDetails -XX:+PrintGCDateStamps -XX:+PrintGCTimeStamps -Xloggc:/logs/gc_user.log"
ENTRYPOINT [ "sh", "-c", "java $JAVA_OPTS -Djava.security.egd=file:/dev/./urandom -Dspring.profiles.active=$RUNTIME_ENV -jar /app.jar" ]